package com.example.service;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.example.mapper.OrdersMapper;

import javax.annotation.Resource;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.Orders;
import com.ruoyi.common.core.domain.TbCustomerOrderDetail;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务处理
 **/
@Service
public class OrdersService {

    @Resource
    private OrdersMapper ordersMapper;

    public Orders selectTbCustomerOrderByOrderNumber(String orderNumber){
        return ordersMapper.selectById(orderNumber);
    };


    /**
     * 删除
     */


    /**
     * 修改订单状态
     */
    public void updateById(Orders orders) {


        ordersMapper.updateById(orders);

        ordersMapper.updateById(orders);
    }



    //根据订单号查数据
    public Orders selectByOrderNo(String orderNo) {
        return ordersMapper.selectByOrderNo(orderNo);
    }

    //查订单详情数据
    public List<TbCustomerOrderDetail> selectDetailByOrderNo(String orderNumber) {
        return ordersMapper.selectDetailByOrderNo(orderNumber);
    }

    //减库存
    public int updateInventoryByDetail(List<TbCustomerOrderDetail> tbCustomerOrderDetails) {

        return ordersMapper.updateInventoryByProductName(tbCustomerOrderDetails);
    }

    //加销量
    public void updateProductByDetail(List<TbCustomerOrderDetail> tbCustomerOrderDetails) {
        ordersMapper.updateProductByDetail(tbCustomerOrderDetails);
    }
}